package com.longcai.piaojia.conn;

import android.text.TextUtils;
import android.util.Log;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONObject;

/**
 * Created by Administrator on 2016/9/22.
 */
@HttpInlet(Conn.ORDER_COUPON)
public class OrderCouponGet extends BaseAsyGet<OrderCouponGet.OrderCouponEntity> {

    public String user_id, classid, money;

    public OrderCouponGet(AsyCallBack<OrderCouponEntity> asyCallBack) {
        super(asyCallBack);
    }

    @Override
    protected OrderCouponEntity parser(JSONObject object) throws Exception {

        TOAST = object.optString("message");

        if (object.optInt("code") == 200) {

            String json = object.optString("data");

            if (!TextUtils.isEmpty(json)){

                JSONObject couponEntity = new JSONObject(json);

                OrderCouponEntity orderCouponEntity = new OrderCouponEntity();

                orderCouponEntity.id = couponEntity.optString("id");
                orderCouponEntity.money = couponEntity.optString("money");
                orderCouponEntity.number = couponEntity.optString("number");
//                orderCouponEntity.type = couponEntity.optString("type");

                Log.e("---------->","1");

                return orderCouponEntity;

            } else {

                OrderCouponEntity orderCouponEntity = new OrderCouponEntity();

                orderCouponEntity.id = "";
                orderCouponEntity.money = "";
                orderCouponEntity.number = "";
//                orderCouponEntity.type = "";

                Log.e("---------->","2");

                return orderCouponEntity;

            }


        }

        return null;
    }

    public static class OrderCouponEntity {

        public String id = "", money = "", number = "";//, type = ""
    }
}
